package com.shijun.tankwar;

import android.graphics.Bitmap;

/**
 * Created by zhushijun on 2018/1/17 0017.
 */

public class FreedomMoveEntity implements SimpleNextFrameAction{

    public static final int TYPE_TANK = 1001;
    public static final int TYPE_SHELL = 1002;

    protected int _id;
    protected int startX;
    protected int startY;
    protected int width;
    protected int height;
    protected Bitmap img;
    protected double orientation;
    protected int speed;
    protected ConfineEntity confine;
    protected int type;

    public FreedomMoveEntity(){}

    public FreedomMoveEntity(int _id,int type,int startX, int startY,int width,int height, Bitmap img, double orientation, int speed) {
        this._id = _id;
        this.type = type;
        this.startX = startX;
        this.startY = startY;
        this.width = width;
        this.height = height;
        this.img = img;
        this.orientation = orientation;
        this.speed = speed;
        confine = new ConfineEntity(_id,startX,startY,startX+width,startY+height);
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public ConfineEntity getConfine() {
        return confine;
    }

    public void setConfine(ConfineEntity confine) {
        this.confine = confine;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getStartX() {
        return startX;
    }

    public void setStartX(int startX) {
        this.startX = startX;
    }

    public int getStartY() {
        return startY;
    }

    public void setStartY(int startY) {
        this.startY = startY;
    }

    public Bitmap getImg() {
        return img;
    }

    public void setImg(Bitmap img) {
        this.img = img;
    }

    public double getOrientation() {
        return orientation;
    }

    public void setOrientation(double orientation) {
        this.orientation = orientation;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    @Override
    public String toString() {
        return "FreedomMoveEntity{" +
                "_id=" + _id +
                ", startX=" + startX +
                ", startY=" + startY +
                ", width=" + width +
                ", height=" + height +
                ", img=" + img +
                ", orientation=" + orientation +
                ", speed=" + speed +
                ", confine=" + confine +
                ", type=" + type +
                '}';
    }

    @Override
    public void nextFrameAction() {
        int addX = (int) (Math.cos(orientation) * getSpeed());
        int addY = -(int) (Math.sin(orientation) * getSpeed());
        setStartX(getStartX() + addX);
        setStartY(getStartY() + addY);
    }

    @Override
    public void isCrash() {

    }

    @Override
    public void registConfine() {
        confine.setMaxX(getStartX());
        confine.setMaxY(getStartY());
        confine.setMinX(getStartX()+width);
        confine.setMinY(getStartY()+height);
    }


}
